// /////////////////////////////////////////////////////////////////////////////
//
// Name:            SkyBoxComponent.h
// Author:          Michael Bartsch (ZCCdark203)
//
// Desc :           Declaration of the SkyBoxComponent class.
//
// License:         Copyright (C) 2009 Michael Bartsch and Contributors
//
//                  This program is free software: you can redistribute it
//                  and/or modify it under the terms of the zlib/libpng License.
//                  See main.cpp for conditions of distribution and use.
//
// /////////////////////////////////////////////////////////////////////////////

#ifndef __SKYBOXCOMPONENT_H__
#define __SKYBOXCOMPONENT_H__

// Include files
#include "../../dependencies.h"
#include "SceneComponent.h"


// SkyBoxComponent class
//! Component wrapper of Irrlicht's SceneManager function addSkyBoxSceneNode(...).
//!
//! <b>XML:</b>
//! \code
//! <SkyBoxComponent>
//!    <!-- Properties -->
//! </SkyBoxComponent>
//! \endcode
class SkyBoxComponent : public SceneComponent
{
public:

    // Initialisation and deinitialisation
    //! Constructor (default)
    //! @param parent        The parent entity to which the component should be added.
    SkyBoxComponent(Entity *parent);
    //! Constructor
    //! @param parent        The parent entity to which the component should be added.
    //! @param top           Texture for the top plane of the box.
    //! @param bottom        Texture for the bottom plane of the box.
    //! @param left          Texture for the left plane of the box.
    //! @param right         Texture for the right plane of the box.
    //! @param front         Texture for the front plane of the box.
    //! @param back          Texture for the back plane of the box.
    //! @note Not available in AngelScript.
    SkyBoxComponent(Entity *parent, ITexture *top, ITexture *bottom, ITexture *left,
                    ITexture *right, ITexture *front, ITexture *back);
    //! Constructor
    //! @param parent        The parent entity to which the component should be added.
    //! @param top           File with the texture for the top plane of the box.
    //! @param bottom        File with the texture for the bottom plane of the box.
    //! @param left          File with the texture for the left plane of the box.
    //! @param right         File with the texture for the right plane of the box.
    //! @param front         File with the texture for the front plane of the box.
    //! @param back          File with the texture for the back plane of the box.
    SkyBoxComponent(Entity *parent, const std::string &top, const std::string &bottom,
                    const std::string &left, const std::string &right, const std::string &front,
                    const std::string &back);
    //! Deconstructor
    ~SkyBoxComponent();

    // Methods
    //! Loads and sets the textures of the sky box.
    //!
    //! <b>XML:</b>
    //! \code
    //! <textures>
    //!    <top type="string" value="" />
    //!    <bottom type="string" value="" />
    //!    <left type="string" value="" />
    //!    <right type="string" value="" />
    //!    <front type="string" value="" />
    //!    <back type="string" value="" /
    //! </textures>
    //! \endcode
    //!
    //! @param top           File with the texture for the top plane of the box.
    //! @param bottom        File with the texture for the bottom plane of the box.
    //! @param left          File with the texture for the left plane of the box.
    //! @param right         File with the texture for the right plane of the box.
    //! @param front         File with the texture for the front plane of the box.
    //! @param back          File with the texture for the back plane of the box.
    //! @param ignoreNull    Should a null value be used as a texture?
    void setTextures(const std::string &top, const std::string &bottom, const std::string &left,
                     const std::string &right, const std::string &front, const std::string &back,
                     bool ignoreNull = true);

    //! Sets the textures of the sky box.
    //! @param top           Texture for the top plane of the box.
    //! @param bottom        Texture for the bottom plane of the box.
    //! @param left          Texture for the left plane of the box.
    //! @param right         Texture for the right plane of the box.
    //! @param front         Texture for the front plane of the box.
    //! @param back          Texture for the back plane of the box.
    //! @param ignoreNull    Should a null value be used as a texture?
    void setTextures(ITexture *top, ITexture *bottom, ITexture *left, ITexture *right,
                     ITexture *front, ITexture *back, bool ignoreNull = true);

    // Events
    //! Responds to changes of a skybox texture attached to this component.
    //! @note For internal use only!
    void onTextureSkyBox(void *p);

    // Serialization
    //! Serializes this object.
    //! @param attributes
    virtual bool onSerialization(SerializedAttributes *attributes);
    //! Deserializes this object.
    //! @param attributes
    virtual bool onDeserialization(SerializedAttributes *attributes);

private:

    //! Common initialisation method.
    void init();

    // Private methods
    void setTexture(u32 side, const std::string &fileName);
    void setTexture(u32 side, ITexture *texture);

    // Private members
    std::string mTextureFileNames[6];
};

#endif
